# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=xerosploit
pkgver=38.e2c3c7b
pkgrel=6
pkgdesc='Efficient and advanced man in the middle framework.'
groups=('blackarch' 'blackarch-networking' 'blackarch-exploitation'
        'blackarch-sniffer')
arch=('any')
url='https://github.com/LionSec/xerosploit'
license=('GPL3')
depends=('python2' 'bettercap' 'nmap' 'hping' 'ruby' 'iproute2' 'net-tools'
         'wireless_tools' 'python2-terminaltables' 'python2-tabulate'
         'python2-sphinx_rtd_theme' 'python2-recommonmark')
makedepends=('git')
source=("git+https://github.com/LionSec/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd $pkgname

  sed 's|("hostname -I").read()|("hostname -i").read().split()[0]|g' \
    -i "$pkgname.py"
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/opt/$pkgname/tools"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm README.md LICENSE

  cp -a * "$pkgdir/opt/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /opt/$pkgname
exec python2 $pkgname.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

